package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.ShoppingCart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper extends BaseMapper<ShoppingCart> {
    
    /**
     * 根据用户ID查询购物车
     */
    @Select("SELECT * FROM shopping_carts WHERE user_id = #{userId}")
    List<ShoppingCart> findByUserId(@Param("userId") Integer userId);
    
    /**
     * 根据用户ID和商品ID查询购物车项
     */
    @Select("SELECT * FROM shopping_carts WHERE user_id = #{userId} AND product_id = #{productId}")
    ShoppingCart findByUserIdAndProductId(@Param("userId") Integer userId, @Param("productId") Integer productId);
} 